
const  state={
    dict: []
};

const getters = {
  /**
   * 得到所有的字典
   */
  getAllDict: (state) => state.dict 
};

const mutations = {
  setDict(state,data) { 
    if (data.key !== null && data.key !== "") { 
     state.dict.push(data);
    }
  },
  removeDict(state){
    state.dict=new Array()
  },
  removeByDictType(state,key){
    let index=-1;
    for (let i = 0; i < state.dict.length; i++) {
      if (state.dict[i].key == _key) {
       index=i;
       break;
      }
    } 
    if(index>=0){
       state.dict.splice(index,1)
    }    
  }
}

const actions = { 
  // 清空字典
  cleanDict({ commit }) {
    commit('removeDict')
  },
  // 初始字典
  initDict({ commit }) {
  }
}  

export default { state, getters, mutations, actions };
